package com.my_musc_service.controller;

import com.my_musc_service.common.R;
import com.my_musc_service.entity.SharedSong;
import com.my_musc_service.service.SharedSongService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * (SharedSong)表控制层
 *
 * @author A.Dun
 * @since 2021-08-17 14:14:27
 */
@RestController
@RequestMapping("sharedSong")
public class SharedSongController extends BaseController{
    /**
     * 服务对象
     */
    @Resource
    private SharedSongService sharedSongService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    public SharedSong selectOne(Integer id) {
        return this.sharedSongService.queryById(id);
    }

    /**
     * 保存分享歌曲
     * @param sharedSong
     * @return
     */
    @PostMapping("add")
    public R addSharedSong(@RequestBody SharedSong sharedSong){
        boolean flag = sharedSongService.insert(sharedSong);
        return isOk(flag);
    }

    @PutMapping("addClickCount")
    public R addClickCount(@RequestBody SharedSong sharedSong){
        Boolean flag=sharedSongService.addClickCount(sharedSong);
        return isOk(flag);
    }


    @PutMapping("delClickCount")
    public R delClickCount(@RequestBody SharedSong sharedSong){
        Boolean flag=sharedSongService.delClickCount(sharedSong);
        return isOk(flag);
    }



}
